package com.it;

import com.it.dao.BookDao;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AppForLifeCycle {
    public static void main(String[] args) {
        //ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        BookDao bookSDao = (BookDao) ctx.getBean("BookDao");
        bookSDao.save();

        // 手工关闭容器
        //ctx.close();

        // 注册关闭钩子，在虚拟机退出前先关闭容器再退出虚拟机
        ctx.registerShutdownHook();
    }
}
